//
//  KTTabBarController.swift
//  KOLToken
//
//  Created by yangsan on 2020/2/26.
//  Copyright © 2020 iOS-team. All rights reserved.
//

import UIKit
import DynamicColor
class KTTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        initUI()
        addChildVC()
        // Do any additional setup after loading the view.
    }
    
    // MARK: - private
    private func initUI() {
        UITabBar.appearance().backgroundColor = DynamicColor(hex: 0xF7F7F7)
        UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor : UIColor.darkGray], for: .normal)
        UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor : UIColor.black], for: .selected)
    }
    
    private func addChildVC() {
        setChildViewController(KTMarketHomeController(), title: "行情", imageName: "icon_menu_statistics")
        setChildViewController(KTNewsHomeViewController(), title: "资讯", imageName: "icon_menu_mycar")
        setChildViewController(KTPersonCenterViewController(), title: "我的", imageName: "icon_driver")
    }
    
    
    private func setChildViewController(_ childController: UIViewController, title: String, imageName: String) {
        childController.tabBarItem.image = UIImage(named: imageName)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        childController.tabBarItem.selectedImage = UIImage(named: imageName)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
           childController.title = title
           let navVc = KTBaseNavgationController(rootViewController: childController)
           addChild(navVc)
       }
 
}
